package com.zh.note.huawei.onehundred.食堂供餐;

import java.util.Scanner;

/**
 * 题目：
 * https://dream.blog.csdn.net/article/details/130906890
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] p = new int[n];
        int total = 0;
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
            total += p[i];
        }
        int res = binarySearchMinSpeed(total, m, p);
        System.out.println(res);
    }

    private static int binarySearchMinSpeed(int total, int m, int[] p) {

        int min = 0;
        int max = total - m;
        int res = max;
        while (min <= max) {
            int mid = min + (max - min) / 2;
            if (canDeliver(mid, m, p)) {
                res = mid;
                max = mid - 1;
            } else {
                min = mid + 1;
            }
        }
        return res;
    }

    private static boolean canDeliver(int speed, int foods, int[] p) {
        for (int i = 0; i < p.length; i++) {
            foods -= p[i];
            if (foods < 0) {
                return false;
            }
            foods += speed;
        }
        return true;
    }
}
